package com.gitee.hermer.engine.jars.core.dubbo;

import org.springframework.beans.factory.InitializingBean;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.gitee.hermer.boot.jee.commons.bean.utils.BeanLocator;
import com.gitee.hermer.boot.jee.commons.exception.ErrorCode;
import com.gitee.hermer.boot.jee.commons.verify.Assert;
import com.gitee.hermer.engine.jars.app.sdk.EngineAppClassLoader;

public class EngineAppDubboConfig extends ApplicationConfig implements InitializingBean{

	public EngineAppDubboConfig() throws Exception {
		try{
			EngineAppClassLoader classLoader = (EngineAppClassLoader) Thread.currentThread().getContextClassLoader();
			setName(classLoader.getCacheKey());
			Assert.notNullCode(BeanLocator.getBean(RegistryConfig.class), ErrorCode.SYSTEM_ERROR,
					"引擎未开启Dubbo支持,请检查是否使用@EnableDubbo");
			setRegistry(BeanLocator.getBean(RegistryConfig.class));
		}catch (Exception e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}

	@Override
	public void afterPropertiesSet() throws Exception {

	}



}
